/*
 * Date: 22/7/2008
 * Author: rcote
 * File: uk.ac.ebi.jmzml.model.mzml.Precursor
 *
 * jmzml is Copyright 2008 The European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *
 *
 */

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-558
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2008.06.19 at 10:48:08 AM BST
//


package uk.ac.ebi.jmzml.model.mzml;

import uk.ac.ebi.jmzml.model.mzml.interfaces.MzMLObject;
import uk.ac.ebi.jmzml.model.mzml.params.ActivationCVParam;
import uk.ac.ebi.jmzml.model.mzml.params.ActivationUserParam;
import uk.ac.ebi.jmzml.model.mzml.params.IsolationWindowCVParam;
import uk.ac.ebi.jmzml.model.mzml.params.IsolationWindowUserParam;
import uk.ac.ebi.jmzml.model.mzml.utilities.ParamGroupUpdater;
import uk.ac.ebi.jmzml.xml.jaxb.adapters.SourceFileAdapter;
import uk.ac.ebi.jmzml.xml.jaxb.adapters.SpectrumAdapter;

import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;


/**
 * The method of precursor ion selection and activation
 * <p/>
 * <p>Java class for PrecursorType complex type.
 * <p/>
 * <p>The following schema fragment specifies the expected content contained within this class.
 * <p/>
 * <pre>
 * &lt;complexType name="PrecursorType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="isolationWindow" type="{http://psi.hupo.org/schema_revision/mzML_1.0.0}ParamGroupType" minOccurs="0"/>
 *         &lt;element name="selectedIonList" type="{http://psi.hupo.org/schema_revision/mzML_1.0.0}SelectedIonListType"/>
 *         &lt;element name="activation" type="{http://psi.hupo.org/schema_revision/mzML_1.0.0}ParamGroupType"/>
 *       &lt;/sequence>
 *       &lt;attribute name="spectrumRef" type="{http://www.w3.org/2001/XMLSchema}IDREF" />
 *       &lt;attribute name="sourceFileRef" type="{http://www.w3.org/2001/XMLSchema}IDREF" />
 *       &lt;attribute name="externalNativeID" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       &lt;attribute name="externalSpectrumID" type="{http://www.w3.org/2001/XMLSchema}string" />
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PrecursorType", propOrder = {
        "isolationWindow",
        "selectedIonList",
        "activation"
        })
public class Precursor
        implements Serializable, MzMLObject {

    private final static long serialVersionUID = 100L;
    protected ParamGroup isolationWindow;
    @XmlElement(required = true)
    protected SelectedIonList selectedIonList;
    @XmlElement(required = true)
    protected ParamGroup activation;
    @XmlAttribute(name = "spectrumRef")
    @XmlJavaTypeAdapter(SpectrumAdapter.class)
    @XmlSchemaType(name = "IDREF")
    protected Spectrum spectrum;
    @XmlAttribute(name = "sourceFileRef")
    @XmlJavaTypeAdapter(SourceFileAdapter.class)
    @XmlSchemaType(name = "IDREF")
    protected SourceFile sourceFile;
    @XmlAttribute
    protected String externalNativeID;
    @XmlAttribute
    protected String externalSpectrumID;

    /**
     * Gets the value of the isolationWindow property.
     *
     * @return possible object is
     *         {@link ParamGroup }
     */
    public ParamGroup getIsolationWindow() {
        return isolationWindow;
    }

    /**
     * Sets the value of the isolationWindow property.
     *
     * @param value allowed object is
     *              {@link ParamGroup }
     */
    public void setIsolationWindow(ParamGroup value) {
        this.isolationWindow = value;
    }

    /**
     * Gets the value of the selectedIonList property.
     *
     * @return possible object is
     *         {@link SelectedIonList }
     */
    public SelectedIonList getSelectedIonList() {
        return selectedIonList;
    }

    /**
     * Sets the value of the selectedIonList property.
     *
     * @param value allowed object is
     *              {@link SelectedIonList }
     */
    public void setSelectedIonList(SelectedIonList value) {
        this.selectedIonList = value;
    }

    /**
     * Gets the value of the activation property.
     *
     * @return possible object is
     *         {@link ParamGroup }
     */
    public ParamGroup getActivation() {
        return activation;
    }

    /**
     * Sets the value of the activation property.
     *
     * @param value allowed object is
     *              {@link ParamGroup }
     */
    public void setActivation(ParamGroup value) {
        this.activation = value;
    }

    /**
     * Gets the value of the spectrum property.
     *
     * @return possible object is
     *         {@link String }
     */
    public Spectrum getSpectrum() {
        return spectrum;
    }

    /**
     * Sets the value of the spectrum property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setSpectrum(Spectrum value) {
        this.spectrum = value;
    }

    /**
     * Gets the value of the sourceFile property.
     *
     * @return possible object is
     *         {@link String }
     */
    public SourceFile getSourceFile() {
        return sourceFile;
    }

    /**
     * Sets the value of the sourceFile property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setSourceFile(SourceFile value) {
        this.sourceFile = value;
    }

    /**
     * Gets the value of the externalNativeID property.
     *
     * @return possible object is
     *         {@link String }
     */
    public String getExternalNativeID() {
        return externalNativeID;
    }

    /**
     * Sets the value of the externalNativeID property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setExternalNativeID(String value) {
        this.externalNativeID = value;
    }

    /**
     * Gets the value of the externalSpectrumID property.
     *
     * @return possible object is
     *         {@link String }
     */
    public String getExternalSpectrumID() {
        return externalSpectrumID;
    }

    /**
     * Sets the value of the externalSpectrumID property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setExternalSpectrumID(String value) {
        this.externalSpectrumID = value;
    }

    private void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
        try {

            //update activation paramGroup
            ParamGroupUpdater.updateParamGroupSubclasses(this.activation, ActivationCVParam.class, ActivationUserParam.class);

            //update ionSelection paramGroup list
            ParamGroupUpdater.updateParamGroupSubclasses(this.isolationWindow, IsolationWindowCVParam.class, IsolationWindowUserParam.class);

        } catch (InstantiationException e) {
            throw new RuntimeException(this.getClass().getName() + ".afterUnmarshall: " + e.getMessage());
        } catch (IllegalAccessException e) {
            throw new RuntimeException(this.getClass().getName() + ".afterUnmarshall: " + e.getMessage());
        }
    }

}
